package com.ruoyi.report_lq.controller;

import java.util.List;
import java.util.Arrays;

import com.ruoyi.report_lq.domain.bo.LqydjlbBaDetailBo;
import com.ruoyi.report_lq.domain.vo.LqydjlbBaDetailVo;
import com.ruoyi.report_lq.service.ILqydjlbBaDetailService;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;

import cn.dev33.satoken.annotation.SaCheckLogin;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 沥青延度记录
 *
 * @author zyb
 * @date 2024-06-11
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/syrw/lqLqydjlbBaDetail")
public class LqydjlbBaDetailController extends BaseController {

    private final ILqydjlbBaDetailService iReportLqLqydjlbBaDetailService;

    /**
     * 查询沥青延度记录列表
     */
    @SaCheckLogin
    @GetMapping("/list")
    public TableDataInfo<LqydjlbBaDetailVo> list(LqydjlbBaDetailBo bo, PageQuery pageQuery) {
        return iReportLqLqydjlbBaDetailService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出沥青延度记录列表
     */
    @SaCheckLogin
    @Log(title = "沥青延度记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(LqydjlbBaDetailBo bo, HttpServletResponse response) {
        List<LqydjlbBaDetailVo> list = iReportLqLqydjlbBaDetailService.queryList(bo);
        ExcelUtil.exportExcel(list, "沥青延度记录", LqydjlbBaDetailVo.class, response);
    }

    /**
     * 获取沥青延度记录详细信息
     *
     * @param liqydid 主键
     */
    @SaCheckLogin
    @GetMapping("/{liqydid}")
    public R<LqydjlbBaDetailVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long liqydid) {
        return R.ok(iReportLqLqydjlbBaDetailService.queryById(liqydid));
    }

    /**
     * 新增沥青延度记录
     */
    @SaCheckLogin
    @Log(title = "沥青延度记录", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody LqydjlbBaDetailBo bo) {
        return toAjax(iReportLqLqydjlbBaDetailService.insertByBo(bo));
    }

    /**
     * 修改沥青延度记录
     */
    @SaCheckLogin
    @Log(title = "沥青延度记录", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody LqydjlbBaDetailBo bo) {
        return toAjax(iReportLqLqydjlbBaDetailService.updateByBo(bo));
    }

    /**
     * 删除沥青延度记录
     *
     * @param liqydids 主键串
     */
    @SaCheckLogin
    @Log(title = "沥青延度记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{liqydids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] liqydids) {
        return toAjax(iReportLqLqydjlbBaDetailService.deleteWithValidByIds(Arrays.asList(liqydids), true));
    }
}
